package org.pb.system.service.impl;

import org.pb.basic.service.impl.BaseServiceImpl;
import org.pb.system.domain.SystemDictionaryType;
import org.pb.system.mapper.SysDicDetailMapper;
import org.pb.system.mapper.SysDicTypeMapper;
import org.pb.system.query.SystemDictionaryTypeQuery;
import org.pb.system.service.ISysDicTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 数据字典对应的业务层实现类
 * @author
 */
@Service
public class SysDicTypeServiceImpl extends BaseServiceImpl<SystemDictionaryType, SystemDictionaryTypeQuery> implements ISysDicTypeService {

    @Autowired
    private SysDicTypeMapper sysDicTypeMapper;

    @Autowired
    private SysDicDetailMapper sysDicDetailMapper;

    @Override
    @Transactional
    public void remove(Long id) {
        if (id == null) {
            throw new RuntimeException("id不能为空");
        }
        // 先删除对应明细表中的所有数据
        sysDicDetailMapper.batchRemoveByType(id);
        // 如果执行成功，则再删除对应的数据字典
        sysDicTypeMapper.remove(id);
    }
}
